<template>
  <div>
     <div class="subject">
    <span>{{val1}}</span>
    <span>+</span>
    <span>{{val2}}</span>
    <span>=</span>
    <input type="number" v-model="val"/>
    <button @click="fn1">提交</button>
  </div>
   </div>
</template>
 
<script>
export default {
  name: "MyMath",
  components: {},
  props: {},
  data() {
    return {
      val1:this.fn(),
      val2:this.fn(),
      val:''
    };
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    fn(){
      return Math.floor(Math.random()*100)
    },
    fn1(){
      const flag=this.val1+this.val2===(+this.val)?1:0
      this.$emit('dealres',flag)
    }
  }
};
</script>

<style scoped>
    .subject {
      margin: 5px;
      padding: 5px;
      font-size: 20px;
    }
    .subject span {
      display: inline-block;
      text-align: center;
      width: 20px;
    }
    .subject input {
      width: 50px;
      height: 20px;
    } 
</style>